Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hashmaps #719

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

kysre
Copy link
Contributor

@kysre kysre commented Jan 26, 2024

@kysre kysre changed the title 598 add support for hashmaps Add support for hashmaps Jan 26, 2024
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 39 lines in your changes are missing coverage. Please review.

Comparison is base (d94a7f9) 61.8% compared to head (d08e922) 61.6%.
Report is 7 commits behind head on master.

❗ Current head d08e922 differs from pull request most recent head d2ce2fa. Consider uploading reports for the commit d2ce2fa to get more accurate results

Files Patch % Lines
tests/test_backend.py 11.7% 38 Missing ⚠️
django_redis/client/default.py 97.2% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #719     +/-   ##
========================================
- Coverage    61.8%   61.6%   -0.1%     
========================================
  Files          43      43             
  Lines        2680    2773     +93     
  Branches      142     161     +19     
========================================
+ Hits         1654    1708     +54     
- Misses       1013    1052     +39     
  Partials       13      13             
Flag Coverage Δ
mypy 38.2% <25.0%> (-0.4%) ⬇️
tests 89.3% <95.3%> (+0.3%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@WisdomPill
Copy link
Member

thanks for the effort @kysre

can you merge master on your branch? just so tests might start to run and your PR will look cleaner?

@WisdomPill WisdomPill changed the base branch from 598-add-support-for-hashmaps to master January 27, 2024 07:19
@WisdomPill
Copy link
Member

never mind I've fixed it

@kysre kysre linked an issue Jan 27, 2024 that may be closed by this pull request
@kysre kysre force-pushed the 598-add-support-for-hashmaps branch from 6e8f76c to 4f815b8 Compare January 27, 2024 19:31
@kysre kysre force-pushed the 598-add-support-for-hashmaps branch from 4f815b8 to 09e53a1 Compare January 27, 2024 23:49
@kysre
Copy link
Contributor Author

kysre commented Jan 28, 2024

I fixed the problem with encoding and decoding values. Now I am getting errors like below in tests:

________________________ TestDjangoRedisCache.test_hlen ________________________
  
  self = <tests.test_backend.TestDjangoRedisCache object at 0x7f4c20da6af0>
  cache = <django.utils.connection.ConnectionProxy object at 0x7f4c218c93a0>
  
      def test_hlen(self, cache: RedisCache):
  >       assert cache.hlen("foo_hash3") == 0
  
  tests/test_backend.py:819: 
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  django_redis/cache.py:29: in _decorator
      return method(self, *args, **kwargs)
  django_redis/cache.py:198: in hlen
      return self.client.hlen(*args, **kwargs)
  django_redis/client/default.py:860: in hlen
      client = self.get_client(write=False)
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
  
  self = <django_redis.client.sharded.ShardClient object at 0x7f4c209f5a60>
  args = (), kwargs = {'write': False}
  
      def get_client(self, *args, **kwargs):
  >       raise NotImplementedError
  E       NotImplementedError
  django_redis/client/sharded.py:27: NotImplementedError

Should I implement hashmap methods in django_redis/client/sharded.py too?

Copy link
Member

@WisdomPill WisdomPill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just a couple of comments.

I think the problem with the tests you wrote is the ShardedClient, you can decide to skip those tests or implement them in the ShardedClient.

If you want your tests to work with shared client just change the get_client method with make_key and get_server based on the key

"""
if client is None:
client = self.get_client(write=False)
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the try/catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented hkeys() similar to keys() function. If you think that the try/catch is redundant, I can remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's okay then, it was implemented way before I took this project, maybe we should discuss it in a separate time

self,
name: str,
client: Optional[Redis] = None,
) -> List:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list of what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it.

@kysre
Copy link
Contributor Author

kysre commented Jan 29, 2024

I decided to skip ShardedClient tests for now. If you think it's better to implement them in ShradedClient, tell me and I'll do it.

@WisdomPill
Copy link
Member

it's okay, I would merge it and then add TODOs in the issue so that other people can take it a step further and add support other commands methods too

@WisdomPill WisdomPill merged commit 81ec264 into jazzband:master Jan 29, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for hashmaps
2 participants